<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../reset.css">
    <style>
        header {
            position: relative;
            width: 100%;
            height: 160px;
            overflow: hidden;
        }

        header div {
            position: absolute;
            top: 0;
            left: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 100%;

            --offset: 0px;
            --blur: 2px;
        }

        header div img {
            display: block;
            width: 110%;
            height: 100%;
            object-fit: cover;

            transform: translateX(var(--offset));
            filter: blur(var(--blur));
        }
    </style>
</head>

<body>
    <header>
        <div><img src="https://assets.codepen.io/2002878/bilibili-autumn-1.png"></div>
        <div><img src="https://assets.codepen.io/2002878/bilibili-autumn-2.png"></div>
        <div><img src="https://assets.codepen.io/2002878/bilibili-autumn-3.png"></div>
        <div><img src="https://assets.codepen.io/2002878/bilibili-autumn-4.png"></div>
        <div><img src="https://assets.codepen.io/2002878/bilibili-autumn-5.png"></div>
        <div><img src="https://assets.codepen.io/2002878/bilibili-autumn-6.png"></div>
    </header>

    <script>
        const imgs = document.querySelectorAll('img');

        document.querySelector('header').addEventListener('mousemove', (e) => {
            let per = e.clientX / window.outerWidth;
            let offset = 10 * per;
            let blur = 20;

            for (const [index, image] of imgs.entries()) {
                offset *= 1.3;

                let blurValue = (Math.pow((index / imgs.length - per), 2) * blur)

                image.style.setProperty('--offset', `${offset}px`)
                image.style.setProperty('--blur', `${blurValue}px`)
            }
        })
    </script>
</body>

</html>